#include "HoldState.h"

#include "CooldownState.h"
#include "StrategyNode.h"

#include <cstddef>


USING_STOCK_NS
using namespace std;

DealState * HoldState::_instance = NULL;

DealState * HoldState::GetInstance()
{
	if (_instance == NULL)
	{
		_instance = new HoldState();
	}

	return _instance;
}

vector<StrategyNode *> HoldState::DoAvailableTransaction(StrategyNode * node, StockPrice curPrice)
{
	vector<StrategyNode *> children;

	StrategyNode * sell_node = new StrategyNode(SELL);
	sell_node->CalcProfit(node->GetProfit(), curPrice);
	sell_node->SetState(CooldownState::GetInstance());
	children.push_back(sell_node);

	StrategyNode * pass_node = new StrategyNode(PASS);
	pass_node->CalcProfit(node->GetProfit(), curPrice);
	pass_node->SetState(HoldState::GetInstance());
	children.push_back(pass_node);

	return children;
}
